/**
 * 获取列表
 * 
 * @param cat
 * @param sort
 * @param inx
 */
function getWriteBookList(inx) {
	$.ajax({
		// async : false,
		type : "POST",
		url : baseUrl + "/write/dedicate-merits-list-part.html?page=" + inx
				+ "&nKeywords=" + $.trim($('#nameKeywordsInput').val()),
		success : function(html) {
			$('#-WRITEBOOK-MAIN-CONTENT-').empty().append(html);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			var msg = XMLHttpRequest.statusText;
			var options = {
				type : SELF_ALERT_TYPES.danger,
				msg : msg,
				hasClose : true,
				time : 3000
			};
			selfAlert(options);
		}
	});
}

$(function() {
	$(
			'.write-content-wrapper .write-main-wrapper .write-main .write-main-content .items-wrapper .items .item')
			.hover(function() {
				var _this = $(this);
				_this.find(".bottom-wrapper").slideDown("fast");
				// resetPage();

			}, function() {
				var _this = $(this);
				_this.find(".bottom-wrapper").slideUp("fast");
			});

	$('#nameKeywordsInput').bind('keydown', function(e) {
		var key = e.which;
		if (key == 13) {
			search();
		}
	});

	// 搜索
	$('#nameKeywordsBtn').click(function() {
		search();
	});
});

function search() {
	var nKeywords = $.trim($('#nameKeywordsInput').val());
	if (!nKeywords) {
		return;
	}
	window.location.href = baseUrl
			+ "/write/dedicate-merits-list.html?nKeywords=" + nKeywords;
}

function resetPage() {
	var buddhismWrapperWidth = $(
			'.write-content-wrapper .write-main-wrapper .write-main .write-main-content .items-wrapper .items .item  .bottom-wrapper .buddhism-wrapper')
			.outerWidth();
	var contentWrapperWidth = $(
			'.write-content-wrapper .write-main-wrapper .write-main .write-main-content .items-wrapper .items .item  .bottom-wrapper .content-wrapper')
			.outerWidth();

	console.info(buddhismWrapperWidth + " " + contentWrapperWidth);

	if ((buddhismWrapperWidth + contentWrapperWidth) > 970) {
		$(
				'.write-content-wrapper .write-main-wrapper .write-main .write-main-content .items-wrapper .items .item  .bottom-wrapper .content-wrapper')
				.outerWidth(970 - buddhismWrapperWidth);
	}

}
